#include<bits/stdc++.h>
using namespace std;
#define int long long

int fun(int n, int m, vector<int> nums) {
	priority_queue<int> q;
	for (int i : nums)
		q.push(i);

	while (m--) {
		int t = q.top();
		q.pop();
		t /= 2;
		q.push(t);
	}

	int ans = 0;
	while (!q.empty()) {
		ans += q.top();
		q.pop();
	}
	return ans;
}

signed main() {
	for (int ii = 1; ii <= 3; ii++) {
		random_device sd;
		mt19937 mt(sd());
		uniform_int_distribution<int> disNM(1, 10);
		uniform_int_distribution<int> disA(1, 1e9);

		freopen((to_string(ii) + ".in").c_str(), "w", stdout);

		int n = disNM(mt);
		int m = disNM(mt);
		cout << n << " " << m << endl;

		vector<int> nums(n);
		for (int i = 1; i <= n; i++) {
			nums[i - 1] = disA(mt);
			cout << nums[i - 1] << " ";
		}
		fclose(stdout);

		freopen((to_string(ii) + ".out").c_str(), "w", stdout);
		cout << fun(n, m, nums) << endl;
		fclose(stdout);
	}
	for (int ii = 4; ii <= 6; ii++) {
		random_device sd;
		mt19937 mt(sd());
		uniform_int_distribution<int> disNM(1, 500);
		uniform_int_distribution<int> disA(1, 1e9);

		freopen((to_string(ii) + ".in").c_str(), "w", stdout);

		int n = disNM(mt);
		int m = disNM(mt);
		cout << n << " " << m << endl;

		vector<int> nums(n);
		for (int i = 1; i <= n; i++) {
			nums[i - 1] = disA(mt);
			cout << nums[i - 1] << " ";
		}
		fclose(stdout);

		freopen((to_string(ii) + ".out").c_str(), "w", stdout);
		cout << fun(n, m, nums) << endl;
		fclose(stdout);
	}
	for (int ii = 7; ii <= 10; ii++) {
		random_device sd;
		mt19937 mt(sd());
		uniform_int_distribution<int> disNM(1, 2e5);
		uniform_int_distribution<int> disA(1, 1e9);

		freopen((to_string(ii) + ".in").c_str(), "w", stdout);

		int n = disNM(mt);
		int m = disNM(mt);
		cout << n << " " << m << endl;

		vector<int> nums(n);
		for (int i = 1; i <= n; i++) {
			nums[i - 1] = disA(mt);
			cout << nums[i - 1] << " ";
		}
		fclose(stdout);

		freopen((to_string(ii) + ".out").c_str(), "w", stdout);
		cout << fun(n, m, nums) << endl;
		fclose(stdout);
	}
	return 0;
}
